<template>
  <div>
    <city-header></city-header>
    <city-search :citiesList = "citiesList"></city-search>
    <city-list
      :hotCities = "hotCities"
      :citiesList = "citiesList"
      :letter = "letter"
    ></city-list>
    <city-alphabet
      :citiesList = "citiesList"
      @change = "handleChange"
    ></city-alphabet>
  </div>
</template>

<script>
import CityHeader from './components/Header.vue'
import CitySearch from './components/search.vue'
import CityList from './components/List.vue'
import CityAlphabet from './components/Alphabet.vue'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      hotCities: [],
      citiesList: {},
      letter: ''
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('/static/mock/city.json').then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.hotCities = data.hotCities
        this.citiesList = data.cities
      }
    },
    handleChange (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style lang="stylus" scoped>

</style>
